package org.cerberus.platform.component.impl;

import static org.cerberus.platform.component.ComponentUtilities.*;

import org.cerberus.platform.component.ComponentUtilities;
import org.cerberus.platform.component.IAttributeListener;
import org.cerberus.platform.component.annotations.Id;
import org.cerberus.platform.component.annotations.PComponent;

@PComponent(classID="ComponentBase")
public class ComponentBase {

	@Id()
	private String id;
	
	public ComponentBase() {
		this.id = generateID();
		init(this);
	}
	
	public ComponentBase(String id) {
		this.id = id;
		init(this);
	}
	
	protected String generateID() {
		return createDefaultID(this);
	}

	public String getId() {
		return id;
	}
	
	public String getGlobalID() {
		return globalID(this);
	}
	
	public void setVisible(boolean visible) {
		ComponentUtilities.setVisible(this, visible);
	}
	
	public boolean isVisible() {
		return ComponentUtilities.isVisible(this);
	}
	
	public void addAttributeListener(String attributeName, IAttributeListener listener) {
		ComponentUtilities.addAttributeListener(this, attributeName, listener);
	}
	
	public void removeAttributeListener(IAttributeListener listener) {
		ComponentUtilities.removeAttributeListener(this, listener);
	}
	
}
